{% extends 'base.html' %}
{% load static %}
{% load mytags %}

{% block script %}
    <script src="{% static 'logs/js/logs_schedule.js' %}"></script>
{% endblock %}

{% block content %}
    {% now 'Y-m-d' as current_date %}
    {% now 'Y' as current_year %}
    {% now 'm' as current_month %}

    <div class="container">
        <div class="row justify-content-md-center">
            <div class="col-md-10">
                <div class="row justify-content-md-center">
                    <div class="btn-group col-md-auto mb-2">
                        {% if has_last_month_schedule %}
                            {% with lyear=current_date|last_month|date:'Y' lmonth=current_date|last_month|date:'m' %}
                                {% if lyear|add:0 != year or lmonth|add:0 != month %}
                                    <a class="btn btn-link btn-success"
                                       title="查看{{ current_date|last_month|date:'Y年m月' }}值班表"
                                       href="{% url 'schedule_list' lyear lmonth %}">查看上个月值班表</a>
                                {% else %}
                                    <a class="btn btn-secondary text-white disabled">查看上个月值班表</a>
                                {% endif %}
                            {% endwith %}
                        {% endif %}
                        {% if current_year|add:0 != year or current_month|add:0 != month %}
                            <a class="btn btn-link btn-success"
                               title="查看{% now 'Y年m月' %}值班表"
                               href="{% url 'schedule_list' current_year current_month %}">查看本月值班表</a>
                        {% else %}
                            <a class="btn btn-secondary text-white disabled">查看本月值班表</a>
                        {% endif %}
                        {% if has_next_month_schedule %}
                            {% with nyear=current_date|next_month|date:'Y' nmonth=current_date|next_month|date:'m' %}
                                {% if nyear|add:0 != year or nmonth|add:0 != month %}
                                    <a class="btn btn-link btn-success"
                                       title="查看{{ current_date|next_month|date:'Y年m月' }}值班表"
                                       href="{% url 'schedule_list' nyear nmonth %}">查看下个月值班表</a>
                                {% else %}
                                    <a class="btn btn-secondary text-white disabled">查看下个月值班表</a>
                                {% endif %}
                            {% endwith %}
                        {% else %}
                            {% with year=current_date|next_month|date:'Y' month=current_date|next_month|date:'m' %}
                                <a class="btn btn-primary" title="创建{{ current_date|next_month|date:'Y年m月' }}值班表"
                                   href="{% url 'create_schedule' year month %}">创建下个月值班表</a>
                            {% endwith %}
                        {% endif %}
                    </div>
                </div>

                <div class="row justify-content-md-center mb-2">
                    <div class="col-md-10">
                        <h2 class="text-center"><span class="text-black-50">{{ year }}年{{ month }}月</span> 值班表</h2>
                    </div>
                </div>

                <table id="schedule-table" class="table table-striped table-hover mb-4">
                    <caption>{{ year }}年{{ month }}月值班表</caption>
                    <thead class="thead-dark">
                    <tr class="row mx-0">
                        <th scope="row" class="col-3">值班日期</th>
                        <th scope="row" class="col-3">安排值班人</th>
                        <th scope="row" class="col-3">实际值班人</th>
                        <th scope="row" class="col-3">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% include 'logs/includes/partial_schedule_list.html' %}
                    </tbody>
                </table>
            </div>
        </div>
        <!-- modal-sign-in -->
        <div class="modal fade" id="modal-sign-in">
            <div class="modal-dialog">
                <div class="modal-content">
                </div>
            </div>
        </div>
    </div>
{% endblock %}

